//logs.js
const util = require('../../utils/util.js')

Page({
  data: {
    sortList: [
      {
        id: 0,
        name: "花茶"
      },
      {
        id: 1,
        name: "红茶"
      },
      {
        id: 2,
        name: "绿茶"
      },
      {
        id: 3,
        name: "白茶"
      }
    ],
    teaList: [
      {
        type: 0,
        name: "玫瑰花茶",
        price: 800.00,
        src: './../../imgs/sort/h1.jpg',
        id: 0
      },
      {
        type: 0,
        name: "茉莉花茶",
        price: 600.00,
        src: './../../imgs/sort/h2.jpeg',
        id: 1
      },
      {
        type: 0,
        name: "菊花茶",
        price: 500.00,
        src: './../../imgs/sort/h3.jpg',
        id: 2
      },
      {
        type: 1,
        name: "正山小种",
        price: 500.00,
        src: './../../imgs/sort/red1.jpg',
        id: 3
      },
      {
        type: 1,
        name: "肉桂",
        price: 1000.00,
        src: './../../imgs/sort/red2.jpg',
        id: 4
      },
      {
        type: 2,
        name: "西湖龙井",
        price: 1500.00,
        src: './../../imgs/sort/l1.jpg',
        id: 5
      },
      {
        type: 3,
        name: "永春佛手",
        price: 1000.00,
        src: './../../imgs/sort/b1.jpg',
        id: 6
      },

    ],
    currentIndex: 0
  },
  onLoad: function () {
    this.setData({
     
    })
  },
  changeSort: function(e) {
    console.log();
    if (e._relatedInfo.anchorTargetText === "花茶"){
      this.setData({
        currentIndex : 0
      })
    } else if (e._relatedInfo.anchorTargetText === "红茶") {
      this.setData({
        currentIndex: 1
      })
    } else if (e._relatedInfo.anchorTargetText === "绿茶") {
      this.setData({
        currentIndex: 2
      })
    }else{
      this.setData({
        currentIndex: 3
      })
    }
  },
  gotoDetail: function(e) {
    let currentId = e.target.id;
    wx.navigateTo({
      //目的页面地址
      url: '/pages/detail/detail?currentId = ' + currentId,
      success: function (res) { 
        console.log('go to detail page success!');
      }
})
  }
})
